<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">
<head th:replace="/layout :: htmlhead" th:with="title='后台管理'">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-form-item" lay-filter="searchForm">
                <form class="layui-form" method="post">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-inline">
                        <input id="nameSearch" name="nameSearch" class="layui-input" type="text"/>
                    </div>
                    <label class="layui-form-label">登录名</label>
                    <div class="layui-input-inline">
                        <input id="loginnameSearch" name="loginnameSearch" class="layui-input" type="text"/>
                    </div>
                </form>
                <div class="layui-input-inline">
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    <button class="layui-btn" lay-submit="" lay-filter="searchSubmit">查询</button>
                </div>
            </div>
            <div class="layui-card">
                <!--<div class="layui-card-header">-->
                <!--</div>-->
                <div class="layui-card-body">
                    <table class="layui-hide" id="table" lay-filter="table"></table>

                    <script type="text/html" id="islock">
                        {{#  if(d.status == 0 || d.status == 5){ }}
                        <input type="checkbox" name="{{d.name}}" value="{{d.id}}" lay-skin="switch"
                               lay-text="启用|停用"
                               lay-filter="islock" checked="checked"/>
                        {{#  } else { }}
                        <input type="checkbox" name="{{d.name}}" value="{{d.id}}" lay-skin="switch"
                               lay-text="启用|停用"
                               lay-filter="islock"/>
                        {{#  } }}
                    </script>

                    <script type="text/html" id="table-title">
                        <h2><b>用户列表</b>&nbsp;&nbsp;&nbsp;<a class="layui-btn layui-btn-normal layui-btn-xs"
                                                                onclick="openAdd()"
                                                                shiro:hasPermission="user:add">新建</a></h2>
                    </script>

                    <script type="text/html" id="table-toolbar">
                        <a class="layui-btn layui-btn-xs" lay-event="edit" shiro:hasPermission="user:edit">编辑</a>
                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"
                           shiro:hasPermission="user:del">删除</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="userEdit" class="layer_self_wrap" style="display:none;">
    <form id="userForm" lay-filter="userForm" class="layui-form layui-form-pane" style="margin-top: 20px;">
        <input id="id" type="hidden" name="id"/>
        <input type="hidden" id="oper" >
        <div class="layui-form-item">
            <label class="layui-form-label">组织机构</label>
            <div class="layui-input-inline" style="width: 70%">
                <input id="organ" type="hidden" name="organ">
                <input id="organName" class="layui-input" type="button" lay-verify="required" onclick="openOrganTree()">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">人员姓名</label>
            <div class="layui-input-inline">
                <input lay-verify="required" name="name" class="layui-input" type="text"/>
            </div>
            <label class="layui-form-label">身份证明号码</label>
            <div class="layui-input-inline">
                <input name="sfzhm" lay-verify="required|identity" class="layui-input" type="text"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否警员</label>
            <div class="layui-input-inline">
                <select name="ispolice">
                    <option value="0">否</option>
                    <option value="1">是</option>
                </select>
            </div>
            <label class="layui-form-label">警员(员工)编号</label>
            <div class="layui-input-inline">
                <input name="jybh" lay-verify="required|bianhao" class="layui-input" type="text"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">登录名</label>
            <div class="layui-input-inline">
                <input lay-verify="required|dlm" name="loginname" class="layui-input" type="text"/>
            </div>
            <label class="layui-form-label">密码</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="button" onclick="resetPassword()" value="点击重置"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">用户类型</label>
            <div class="layui-input-inline">
                <select name="usertype">
                    <option value="0">管理员</option>
                    <option value="1" selected="selected">用户</option>
                </select>
            </div>
            <label class="layui-form-label">角色</label>
            <div class="layui-input-inline">
                <select id="role_id" name="role_id">
                    <option value="">请选择</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-inline">
                <select name="sex">
                    <option value="1">女</option>
                    <option value="0">男</option>
                </select>
            </div>
            <label class="layui-form-label">年龄</label>
            <div class="layui-input-inline">
                <input name="age" lay-verify="nianling" class="layui-input" type="text"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">电话</label>
            <div class="layui-input-inline">
                <input name="phone" lay-verify="dianhua" class="layui-input" type="text"/>
            </div>
            <label class="layui-form-label">用户状态</label>
            <div class="layui-input-inline">
                <select name="status">
                    <option value="0">正常</option>
                    <option value="1">停用</option>
                    <option value="2">锁定</option>
                    <option value="5">待激活</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">账户有效期</label>
            <div class="layui-input-inline">
                <input id="zhyxq" lay-verify="required|date" name="zhyxq" class="layui-input" type="text"/>
            </div>
            <label class="layui-form-label">密码有效期</label>
            <div class="layui-input-inline">
                <input id="mmyxq" lay-verify="required|date" name="mmyxq" class="layui-input" type="text"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">工作开始时间</label>
            <div class="layui-input-inline">
                <input name="daystart" id="gzks" lay-verify="required" class="layui-input" type="text"/>
            </div>
            <label class="layui-form-label">工作结束时间</label>
            <div class="layui-input-inline">
                <input name="dayend" id="gzjs" lay-verify="required" class="layui-input" type="text"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">IPS</label>
            <div class="layui-input-inline" style="width: 70%">
                <input name="ips" lay-verify="required|newpassword" class="layui-input" type="text"/>
            </div>
        </div>
        <div class="layui-form-item"style="float: right; margin-right: 50px;margin-top:50px">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submitUser" >确定</button>
                <button type="button" class="layui-btn layui-btn-primary"  onclick="submitCancel()" >取消</button>
            </div>
        </div>
    </form>

</div>
<div id="organDiv" class="layer_self_wrap" style="display:none;">
    <div id="organTree"></div>
</div>
<script>
    layui.use(['form', 'layedit', 'laydate'],function () {
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;
        var editIndex = layedit.build('LAY_demo_editor');
        //    自定义验证
        form.verify({
            bianhao:[
                /^[a-zA-Z0-9]{0,9}$/
                ,'警员编号不超过10位'
            ]
            ,dlm:[
                /[^\u4e00-\u9fa5]+$/
                ,'不能是中文字符'
            ]
            ,nianling:[
                /^$|^[0-9]*$/
                ,'年龄为数字'
            ]
            ,dianhua:[
                /^$|^[1][3,4,5,7,8][0-9]{9}$/
                ,'手机号不合法'
            ]
            // ,ips: [
            //     /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
            //     ,'IP地址不符合规则'
            // ]

            ,content: function(value){
                layedit.sync(editIndex);
            }
        })
        laydate.render({
            elem: '#gzks',
            type: 'time',
            format: 'HHmmss',
            btns: ['clear', 'confirm']
        });
        laydate.render({
            elem: '#gzjs',
            type: 'time',
            format: 'HHmmss',
            btns: ['clear', 'confirm']
        });
    })

</script>
<script th:src="@{/js/systemManager/user.js}"></script>
</body>
</html>